home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ZED3DSRC.ZIP / DOSFUNC.C < prev    next >
C/C++ Source or Header  |  1995-06-17  |  1KB  |  113 lines

  1. /*
  2.  * Copyright (C) 1995 by Sébastien Loisel All Rights Reserved
  3.  *
  4.  * OS-dependant functions
  5.  */
  6.  
  7.  
  8.  
  9.  
  10. #include <dosfunc.h>
  11. #include <dos.h>
  12.  
  13.  
  14. unsigned long far *screen;
  15.  
  16. void _to256(void)
  17.     {
  18.     union REGS r;
  19.  
  20.     r.x.ax=0x13;
  21.  
  22.     int86(0x10,&r,&r);
  23.     outp(0x3c2,0xe3);
  24.     }
  25.  
  26.  
  27. void _totxt(void)
  28.     {
  29.     union REGS r;
  30.  
  31.     r.x.ax=0x3;
  32.     int86(0x10,&r,&r);
  33.     }
  34.  
  35. void setpalette(color *palette, int col1, int col2)
  36.     {
  37.     outp(0x3c8,col1);
  38.     while(col1<=col2)
  39.         {
  40.         outp(0x3c9,palette->r);
  41.         outp(0x3c9,palette->g);
  42.         outp(0x3c9,palette->b);
  43.         palette++;
  44.         col1++;
  45.         }
  46.     }
  47.  
  48.  
  49.  
  50. void setgrayscale(int col1, int col2)
  51.     {
  52.     color p[256];
  53.     int x,y;
  54.  
  55.     for(x=col1;x<=col2;x++)
  56.         {
  57.         y=(col2-x)*63/(col2-col1);
  58.         p[x-col1].r=y;
  59.         p[x-col1].g=y;
  60.         p[x-col1].b=y;
  61.         }
  62.  
  63.     setpalette(p,col1,col2);
  64.     }
  65.  
  66.  
  67.  
  68. #ifdef __BORLANDC__
  69. void to256(void)
  70.     {
  71.     screen=((unsigned char far *)0xa0000000);
  72.     _to256();
  73.     }
  74.  
  75. void totxt(void)
  76.     {
  77.     _totxt();
  78.     }
  79.  
  80. #else
  81. /* Zortech version I hope... */
  82. void to256(void)
  83.     {
  84.     screen=_x386_mk_protected_ptr(0xa0000);
  85.     _to256();
  86.     }
  87.  
  88. void totxt(void)
  89.     {
  90.     _totxt();
  91.     }
  92. #endif
  93.  
  94.  
  95. void blit(outbuffer *out)
  96.     {
  97.     long x,y,z;
  98.     pixel *p;
  99.     long *b;
  100.  
  101.     p=out->buffer;
  102.     for(y=0;y<out->height;y++)
  103.         {
  104.         z=(y<<6)+(y<<4);
  105.         b=(long *)p;
  106.         for(x=0;x<(out->width>>2);x++)
  107.             {
  108.             screen[z+x]=b[x];
  109.             }
  110.         p+=out->width;
  111.         }
  112.     }
  113.